#include "user_print.h"
#include "stm32f405xx.h"
#include<stdio.h>
#include<string.h>
#include"gdb_server.h"
#include"main.h"
#define UART_TC (1 << 6)

static void uart_send_ch(char ch)
{
    while (0 == ((USART6->SR)&UART_TC));
    USART6->DR = ch;
}
void uart_send_string(char *str,unsigned int len)
{
    unsigned int i;
    
    for(i=0;i<len;i++)
    uart_send_ch(str[i]);
    // HAL_UART_Transmit()
}
int user_printf(char*fmt,...)
{
    va_list ap; 
    char user_string[256];
    int ret;
    va_start(ap, fmt); 
    ret=vsprintf(user_string,fmt,ap); 
    if(monitor_flag)
    {
        monitor_output_string(user_string);
    }
    uart_send_string(user_string,ret);

    va_end(ap);
    return ret;
}